package com.hzhr.iot.cqgas.ds.service;

import com.hzhr.iot.cqgas.ds.dao.device.example.DevOptionsDao;
import com.hzhr.iot.cqgas.ds.entity.device.DevOptionsEntity;
import com.hzhr.iot.cqgas.ds.entity.device.DevOptionsExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DevOptionsService {
    @Autowired
    DevOptionsDao devOptionsDao;

    public String getCode(String typeName, String name) {
        DevOptionsExample devOptionsExample = new DevOptionsExample();
        devOptionsExample.createCriteria()
                .andTypeNameEqualTo(typeName)
                .andNameEqualTo(name);
        List<DevOptionsEntity> devOptionsEntities = devOptionsDao.selectByExample(devOptionsExample);
        if (devOptionsEntities.size() == 0) return null;
        return devOptionsEntities.get(0).getCode();
    }
}
